<?php
if ( IPB_THIS_SCRIPT != 'admin' )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'init.php'.";
	exit();
}

class ad_item_logs
{
	var $ipsclass;
	var $LIMIT = 50;
	
	function auto_run()
	{
		$this->ipsclass->input['st'] = intval($this->ipsclass->input['st']);
		
		$this->ipsclass->admin->page_title  = "Welcome to logs page for the Bank";
		$this->ipsclass->admin->page_detail = "Welcome to logs page for the Bank";
		
		$this->ipsclass->DB->build_and_exec_query(array('select'=>'1','from'=>'market_item_logs'));
		$total_count = $this->ipsclass->DB->get_num_rows();
		
		$page = $this->ipsclass->adskin->build_pagelinks(	array(	'TOTAL_POSS'   => $total_count,
																	'PER_PAGE'     => $this->LIMIT,
																	'USE_ST'       => 'st',
																	'CUR_ST_VAL'   => $this->ipsclass->input['st'],
																	'L_SINGLE'     => "Single Page",
																	'BASE_URL'     => $this->ipsclass->base_url."&amp;".$this->ipsclass->form_code."&amp;ACT=logs"
															)	);

		$this->ipsclass->html .= $this->ipsclass->adskin->add_standalone_row($page,"left");
		
		$this->ipsclass->html .= "<br />";
		
		$this->ipsclass->adskin->td_header[] = array( "Item"        , "" );
		$this->ipsclass->adskin->td_header[] = array( "IP Address"  , "" );
		$this->ipsclass->adskin->td_header[] = array( "Member"      , "" );
		$this->ipsclass->adskin->td_header[] = array( "Time"        , "" );
		$this->ipsclass->adskin->td_header[] = array( "Message"     , "" );
		
		$this->ipsclass->html .= $this->ipsclass->adskin->start_table("Item Logs");
		
		$this->ipsclass->DB->build_query(array(
												'select' => 'l.*',
												'from' => array('market_item_logs'=>'l'),
												'add_join' => array(
																		array(
																				'select' => 'm.members_display_name',
																				'from' => array('members'=>'m'),
																				'where' => "m.id=l.member_id",
																				'type' => 'left'
																			),
																	),
												'order' => 'l_id DESC',
												'limit' => array($this->ipsclass->input['st'],$this->LIMIT)
										)	);
		$this->ipsclass->DB->exec_query();
		while($log = $this->ipsclass->DB->fetch_row())
		{
			$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(  $this->ipsclass->cache['market_items'][$log['item_id']]['item_name'],
																				  $log['ip_address'],
																				  $log['members_display_name'],
																				  $this->ipsclass->get_date($log['l_time'],'LONG'),
																				  $log['log_message']
																		 )      );
		}
		
		$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
		
		$this->ipsclass->html .= $this->ipsclass->adskin->add_standalone_row($page,"left");
		
		$this->ipsclass->admin->output();
	}
	
}
?>